package net.xdclass.controller;

import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/ai")
public class AiController {

    @Autowired
    private OpenAiChatModel chatModel;

    @GetMapping("/generate")
    public Map<String, String> generate(@RequestParam("msg") String msg) {
        String call = chatModel.call(msg);

        return Map.of("msgg", call);
    }
}
